#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 105;

int n, m;
struct Node {
  ll x1, y1, x2, y2;
} a[N];

bool check(int n) {
  ll w = 0;
  ll wx = 0;
  ll wy = 0;
  per(i, n, 2) {
    ll d = a[i].x2 - a[i].x1;
    ll now = d * d * d;
    w += now;
    wx += now * (a[i].x1 + a[i].x2);
    wy += now * (a[i].y1 + a[i].y2);
    ll x1 = w * a[i - 1].x1 * 2;
    ll x2 = w * a[i - 1].x2 * 2;
    if (wx < x1 || wx > x2) return false;
    ll y1 = w * a[i - 1].y1 * 2;
    ll y2 = w * a[i - 1].y2 * 2;
    if (wy < y1 || wy > y2) return false;
  }
  return true;
}
void solve() {
  cin >> n;
  rep(i, 1, n) cin >> a[i].x1 >> a[i].y1 >> a[i].x2 >> a[i].y2;
  rep(i, 1, n) {
    if (a[i].x1 > a[i].x2) swap(a[i].x1, a[i].x2);
    if (a[i].y1 > a[i].y2) swap(a[i].y1, a[i].y2);
  }
  rep(i, 2, n) {
    if (!check(i)) {
      cout << i - 1;
      return;
    }
  }
  cout << n;
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}